#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int dominantIndex(vector<int>& nums) {
        vector<int> v1(nums.begin(), nums.end());
        sort(v1.begin(), v1.end(), greater<int>());
        if (v1[0] >= v1[1] * 2)
        {
            for (int i = 0; i < nums.size(); i++)
            {
                if (nums[i] == v1[0])
                {
                    return i;
                }
            }
        }

        return -1;
    }
};